package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(LeaseException.class)
    public Result<LeaseException> error(LeaseException e){
        ResultCodeEnum resultCodeEnum=e.getResultCodeEnum();
        e.printStackTrace();
        return Result.build(null,resultCodeEnum);
    }
    @ExceptionHandler(Exception.class)
    public Result<Exception> error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
